﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefEquipAlarmRecord" :model="stateEquipAlarmRecord.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_EquipAlarmRecord_ProductId')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.ProductId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipmentId_FormItem" prop="Entity.EquipmentId" :label="$t('message.autotrans._Model_EquipAlarmRecord_Equipment')">
            <el-select v-model="stateEquipAlarmRecord.vmModel.Entity.EquipmentId" disabled clearable>
               <el-option v-for="item in stateEquipAlarmRecord.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipCode_FormItem" prop="Entity.EquipCode" :label="$t('message.autotrans._Model_EquipAlarmRecord_EquipCode')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.EquipCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipName_FormItem" prop="Entity.EquipName" :label="$t('message.autotrans._Model_EquipAlarmRecord_EquipName')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.EquipName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpCode_FormItem" prop="Entity.OpCode" :label="$t('message.autotrans._Model_EquipAlarmRecord_OpCode')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.OpCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Address_FormItem" prop="Entity.Address" :label="$t('message.autotrans._Model_EquipAlarmRecord_Address')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.Address" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Bits_FormItem" prop="Entity.Bits" :label="$t('message.autotrans._Model_EquipAlarmRecord_Bits')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_Bits')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.Bits" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Content_FormItem" prop="Entity.Content" :label="$t('message.autotrans._Model_EquipAlarmRecord_Content')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_Content')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.Content" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Level_FormItem" prop="Entity.Level" :label="$t('message.autotrans._Model_EquipAlarmRecord_Level')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_Level')}), trigger: 'blur' }]" >
            <el-select v-model="stateEquipAlarmRecord.vmModel.Entity.Level" disabled clearable>
               <el-option key="L1" value="L1" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L1')"></el-option>
               <el-option key="L2" value="L2" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L2')"></el-option>
               <el-option key="L3" value="L3" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L3')"></el-option>
               <el-option key="L4" value="L4" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L4')"></el-option>
               <el-option key="L5" value="L5" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L5')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Classify_FormItem" prop="Entity.Classify" :label="$t('message.autotrans._Model_EquipAlarmRecord_Classify')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_Classify')}), trigger: 'blur' }]" >
            <el-select v-model="stateEquipAlarmRecord.vmModel.Entity.Classify" disabled clearable>
               <el-option key="Robot" value="Robot" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Robot')"></el-option>
               <el-option key="EStop" value="EStop" :label="$t('message.autotrans._Enum_AlarmTypeEnum_EStop')"></el-option>
               <el-option key="SensorOver" value="SensorOver" :label="$t('message.autotrans._Enum_AlarmTypeEnum_SensorOver')"></el-option>
               <el-option key="Cylinder" value="Cylinder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Cylinder')"></el-option>
               <el-option key="Raster" value="Raster" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Raster')"></el-option>
               <el-option key="Welder" value="Welder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welder')"></el-option>
               <el-option key="Servo" value="Servo" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Servo')"></el-option>
               <el-option key="Welding" value="Welding" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welding')"></el-option>
               <el-option key="Vision" value="Vision" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Vision')"></el-option>
               <el-option key="Airtight" value="Airtight" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Airtight')"></el-option>
               <el-option key="General" value="General" :label="$t('message.autotrans._Enum_AlarmTypeEnum_General')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Duration_FormItem" prop="Entity.Duration" :label="$t('message.autotrans._Model_EquipAlarmRecord_Duration')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.Duration" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Status_FormItem" prop="Entity.Status" :label="$t('message.autotrans._Model_EquipAlarmRecord_Status')">
            <el-select v-model="stateEquipAlarmRecord.vmModel.Entity.Status" disabled clearable>
               <el-option key="Doing" value="Doing" :label="$t('message.autotrans._Enum_AlarmStatusEnum_Doing')"></el-option>
               <el-option key="Close" value="Close" :label="$t('message.autotrans._Enum_AlarmStatusEnum_Close')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_AlarmStatusEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StartTime_FormItem" prop="Entity.StartTime" :label="$t('message.autotrans._Model_EquipAlarmRecord_StartTime')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_StartTime')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.StartTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EndTime_FormItem" prop="Entity.EndTime" :label="$t('message.autotrans._Model_EquipAlarmRecord_EndTime')">
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.EndTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_EquipAlarmRecord_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipAlarmRecord_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipAlarmRecord.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseEquipAlarmRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipAlarmRecordDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipalarmrecordApi } from '/@/api/equipmentmanagement/equipalarmrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipAlarmRecord = ref();
const stateEquipAlarmRecord = reactive({
    vmModel: {
	  Entity:{
        ProductId: null,
        EquipmentId: null,
        EquipCode: '',
        EquipName: '',
        OpCode: '',
        Address: '',
        Bits: null,
        Content: '',
        Level: undefined,
        Classify: undefined,
        Duration: null,
        Status: undefined,
        StartTime: undefined,
        EndTime: undefined,
        IsValid: undefined,
        ID:null,
      },

	},
    
    AllEquipments: [] as any[],
});

// 取消
const onCloseEquipAlarmRecord = () => {
    closeDialog();
};

// 提交
const onSubmitEquipAlarmRecord = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefEquipAlarmRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipalarmrecordApi().edit(stateEquipAlarmRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipAlarmRecord/GetEquipments',[],false).then(x=>{stateEquipAlarmRecord.AllEquipments = x});
    if (ci.attrs["wtmdata"]) {
		stateEquipAlarmRecord.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipAlarmRecord.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	equipalarmrecordApi().get(stateEquipAlarmRecord.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateEquipAlarmRecord.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

